package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._02策略模式._6商品价格策略工厂;

/**
 * @ClassName CashContext
 * @Description TODO
 * @Author zero
 * @DATE 2023/7/10 1:10 PM
 * @Version 1.0
 */
public class CashContext {
    private CashSuper cashSuper;
    public CashContext(int discount) {
        switch (discount){
            case 1:
                this.cashSuper = new CashNormal();
                break;
            case 2:
                this.cashSuper = new CashRebate(0.8d);
                break;
            case 3:
                this.cashSuper = new CashRebate(0.7d);
                break;
            case 4:
                this.cashSuper = new CashReturn(300d,100d);
                break;
        }
    }

    public double getResult(double price, int num) {
        return this.cashSuper.acceptCash(price,num);
    }
}
